package com.estate.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.NumberFormat;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.OffsetDateTime;
import java.util.List;

// 定义Property类
@Data
@ToString
public class HomeSaleDataView {
    private Long listingId;
    private String listingTitle;
    private String state;
    private String transactionType;
    private String suburb;
    private String status;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    private OffsetDateTime daysOnMarket;

    private String onMarketDate;

    private String address;
    private Integer bed;
    private Integer bath;
    private Integer car;
    private Integer landsize;
    private Integer floorsize;
    @NumberFormat(pattern = "#,###")
    private BigDecimal price;

    private String auctionDate;

    private String saleDate;

    private String type;
    private String propertyType;
    private String agency;
    private String agent;

    // 添加格式化方法，在需要时调用
    public String getOnMarketDate() {
        if (onMarketDate != null && onMarketDate.length() > 10) {
            return onMarketDate.substring(0, 10);
        }
        return onMarketDate;
    }

    public String getAuctionDate() {
        if (auctionDate != null && auctionDate.length() > 10) {
            return auctionDate.substring(0, 10);
        }
        return auctionDate;
    }

    public String getSaleDate() {
        if (saleDate != null && saleDate.length() > 10) {
            return saleDate.substring(0, 10);
        }
        return saleDate;
    }

    public String getPrice() {
        if (price == null) {
            return "";
        }
        // 使用DecimalFormat进行格式化
        DecimalFormat df = new DecimalFormat("#,###");
        return df.format(price);
    }

    // 如果还需要带货币符号的格式
    public String getFormattedPriceWithCurrency() {
        if (price == null) {
            return "";
        }
        DecimalFormat df = new DecimalFormat("$#,###");
        return df.format(price);
    }
//--------------------------以下是查询使用参数---------------------------------------
    //【"On Market", "Under Contract", "Under Offer", "Sold", "Leased", "Settled"】
    //【"在售", "已签约", "已报价", "已售", "已租", "已交割"】
    private String listingStatus;
    //交易类型(auction/exclusive/open/conjunctional/private treaty)
    private String listingTransactionType;
    //排序类型 1 房产上架时 2房产信息更新时间 3 房屋价格
    private String sortType;
    //房屋区域
    private String listingArea;
    //邮箱列表
    List<String> emailList;


}